package com.quxian.chambercommerce.dao.impl;

import java.util.List;
import java.util.Map;

import com.quxian.chambercommerce.base.BaseDaoSupport;
import com.quxian.chambercommerce.bean.MemberInfoEntity;
import com.quxian.chambercommerce.bean.StaffInfoEntity;
import com.quxian.chambercommerce.dao.LoginDao;

public class LoginDaoImpl extends BaseDaoSupport implements LoginDao {

	public StaffInfoEntity login(String loginName) {
		StaffInfoEntity staff = (StaffInfoEntity)this.getSqlMapClientTemplate().queryForObject("Login.staffLogin", loginName);
		return staff;
	}

	@Override
	public MemberInfoEntity memberLogin(String loginName) {
		return (MemberInfoEntity) this.getSqlMapClientTemplate().queryForList("Login.memberLogin", loginName);
	}

	@Override
	public Integer registerStaff(StaffInfoEntity staff) {
		return (Integer) this.getSqlMapClientTemplate().insert("Login.registerStaff", staff);
	}

	@Override
	public Integer registerMember(MemberInfoEntity member) {
		return (Integer) this.getSqlMapClientTemplate().insert("Login.registerMember", member);
	}

	@Override
	public void updateStaff(Map<String, Object> map) {
		this.getSqlMapClientTemplate().update("Login.updateStaff", map);
	}

	@Override
	public Integer checkStaffOnly(String userName) {
		return (Integer) this.getSqlMapClientTemplate().queryForObject("Login.checkStaffOnly",userName);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<StaffInfoEntity> getAllStaff() {
		return this.getSqlMapClientTemplate().queryForList("Login.getAllStaff");
	}

	@Override
	public void deleteStaffById(Integer staffId) {
		this.getSqlMapClientTemplate().delete("Login.deleteStaffById", staffId);		
	}

	@Override
	public StaffInfoEntity getStaffById(Integer staffId) {
		return (StaffInfoEntity) this.getSqlMapClientTemplate().queryForObject("Login.getStaffById", staffId);
	}


}
